package com.yanqu.road.server.cmd.relatives;

import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.relatives.RelativesProto;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.command.Command;
import com.yanqu.road.server.manger.relatives.RelativesMgr;
import com.yanqu.road.server.protocol.Protocol;
import io.netty.channel.ChannelHandlerContext;

@Cmd(code = Protocol.S_RELATIVES_WRITE_LETTER_FROM_CROSS, desc = "写信")
public class WriteLetterFromCrossCmd implements Command {

    @Override
    public void execute(ChannelHandlerContext ctx, YanQuMessage yanQuMessage) throws Exception {

        RelativesProto.CrossWriteLetterReqMsg reqMsg = RelativesProto.CrossWriteLetterReqMsg.parseFrom(yanQuMessage.getBytes());
        RelativesMgr.writeLetterFromCross(reqMsg.getRelativesId(), reqMsg.getFromUserId(), reqMsg.getFromServerId(), reqMsg.getContent(), reqMsg.getWriteNum());
    }
}
